/*
 *  composite.h
 *  EPPI-0.0
 *
 *  Created by Sergio Conde Martin on 6/02/13.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */
 
#ifndef _composite_h_
#define _composite_h_

#include <iostream>
#include <sstream>
#include "MATERIALS/material.h"

using namespace std;

class Composite : public Material
{
public:
	Material *matGround;

private:
	int nf;                  // Number of family fibers
	vector < double > va0;	 // Family fiber directions, 3 * nf x 1.
	double k1;               // Stress-like parameter material GHO
    double k2;               // Dimension-less parameter material GHO
    double kappa;            // Dispersion parameter material GHO
    
    double IVm;              // Fourth invariant which measures the first family of fibers elongation IVm = (a0 x a0) : Cm
    double VIm;              // Sixth invariant which measures the second family of fibers elongation VIm = (b0 x b0) : Cm

    double Wf;               // Fibered part of the free energy function
    double WfIm1;            // First derivative of the fibered part of the free-energy respect to the first modified invariant
    double WfIm2;            // First derivative of the fibered part of the free-energy respect to the first modified invariant
    double WfIVm;            // First derivative of the fibered part of the free-energy respect to the fourth modified invariant
    double WfVIm;            // First derivative of the fibered part of the free-energy respect to the sixth modified invariant
    double WfIm1Im1, WfIm2Im2, WfIm1IVm, WfIVmIm1;
    double WfIVmIVm, WfVImVIm, WfIm2VIm, WfVImIm2;
    
    VectorXd Sf;			//
    MatrixXd Ctf;		 	//

    double norm2a0, norm2b0;

    Tensor2Sym SfTens, mSfTens;
    Tensor2Sym A0, B0;       // structural Tensors A0i = a0 x a0 and B0i = b0 x b0.
    Tensor4LSym mCtfTens, CtfTens;
    
public:
    Composite();
    Composite(ifstream &, const string &, const string &,  Material*);
    ~Composite(){}
	
    /** Virtual functions from base */
    void calcW( const VectorXd & );
    void calcS( const VectorXd & );		// Computes the hyperelastic Second Piola-Kirchoff Stress Tensor
    void calcSiso (const VectorXd &);
    void calcCt( const VectorXd & );	// Computes the constitutive material tensor

    int getNfibers();
	
    /**Local Function */
    
    void calcAnisoTerms( const VectorXd & );
};

#endif
